package com.tencent.controller;

import com.tencent.entity.Result;
import com.tencent.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @BelongsProject: health2.2
 * @BelongsPackage: com.tencent.controller
 * @ClassName: LoginController
 * @Description: TODO
 * @Version: 1.0.0
 * @CreateTime: 2022-09-01  14:45
 * @Author: Yangjx
 */
@RestController
@RequestMapping("/memberId")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @GetMapping
    public Result getByName(String name, HttpServletRequest request){

        //测试解析jwt,取username
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Object username = authentication.getPrincipal();
//        System.out.println("LoginController --> 取username = " + username);

        return Result.success("取username");
    }

}
